<template>
  <view>
    <view class="kpzy" @click="newqa">指引</view>
    <view class="card" v-for="(item,k) in list" :key="k" @click="toopen(item)">
      <view class="timebox">
        <view class="time">
          <text v-if="item.invoiceTypeEnum.key==2">个人发票</text>
          <text v-if="item.invoiceTypeEnum.key==1">企业发票</text>
          ：{{item.createTime}}
        </view>
        <view class="status">{{item.invoiceConditionEnum.value}}</view>
      </view>
      <view class="name">{{item.name}}</view>
      <view class="emailbox">
        <view class="email">{{item.email?item.email:'邮箱：------'}}</view>
        <view class="price">
          <text class="money">￥</text>
          {{item.invoiceValue }}
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      list: [],
      pageNum: 1,
      pageSize: 10,
      finish: false,
    };
  },
  methods: {
    newqa() {
      uni.navigateTo({
        url: "/pages/newqa/newqa",
      });
    },
    toopen(item) {
      uni.navigateTo({
        url:
          "/pages/invoiceDetails/invoiceDetails?item=" + JSON.stringify(item),
      });
    },
    getList() {
      if (this.finish) {
        return;
      }
      uni.showLoading({
        title: "加载中",
        mask: true,
      });
      this.$http
        .get(
          "/invoiceRecord/list",
          {
            phoneNumber: uni.getStorageSync("phone"),
            pageSize: this.pageSize,
            pageNum: 1,
          },
          {
            header: {
              "content-type": "application/json;charset=UTF-8",
            } /* 会覆盖全局header */,
            dataType: "json",
            responseType: "text",
          }
        )
        .then((res) => {
          uni.hideLoading();
          let data = res.data;
          uni.stopPullDownRefresh();
          if (data.code == 0) {
            data.data.rows.forEach((item) => {
              item.createTime = this.$moment(item.createTime).format(
                "YYYY-MM-DD HH:mm"
              );
            });
            console.log(data.data.rows);
            this.list = data.data.rows;
            if (data.data.rows.length == data.data.total) {
              this.finish = true;
            }
          } else {
            uni.showToast({
              image: "/static/img/warn.png",
              title: data.msg,
              duration: 2000,
              mask: true,
            });
          }
        });
    },
  },
  onShow() {
    // this.pageSize = (this.pageNum + 1) * 10;
    this.finish = false;
    this.getList();
  },
  onReachBottom() {
    this.pageNum = this.pageNum + 1;
    this.pageSize = this.pageNum * 10;
    this.getList();
  },
  onPullDownRefresh() {
    this.finish = false;
    this.pageNum = 1;
    this.pageSize = 10;
    this.getList();
  },
};
</script>

<style scoped>
.card {
  width: 702rpx;
  height: 240rpx;
  background: rgba(255, 255, 255, 1);
  border: 1px solid rgba(245, 245, 245, 1);
  box-shadow: 0px 8rpx 10rpx 0px rgba(0, 0, 0, 0.1);
  border-radius: 16rpx;
  padding: 41rpx 24rpx;
  margin: auto;
  margin-top: 20rpx;
}
.timebox {
  display: flex;
  justify-content: space-between;
  font-size: 28rpx;
  font-family: PingFang SC;
  font-weight: 500;
  color: rgba(0, 0, 0, 1);
}
.name {
  font-size: 32rpx;
  font-family: PingFang SC;
  font-weight: bold;
  color: rgba(0, 0, 0, 1);
  margin-top: 20rpx;
}
.emailbox {
  display: flex;
  justify-content: space-between;
  margin-top: 20rpx;
  font-size: 28rpx;
  font-family: PingFang SC;
  font-weight: 500;
  color: rgba(0, 0, 0, 1);
}
.price {
  font-size: 40rpx;
  font-family: PingFang SC;
  font-weight: bold;
  color: rgba(0, 0, 0, 1);
}
.money {
  font-size: 24rpx;
  font-family: PingFang SC;
  font-weight: bold;
  color: rgba(0, 0, 0, 1);
  margin-right: 10rpx;
}
.kpzy {
  position: fixed;
  right: 10px;
  bottom: 186px;
  height: 40px;
  width: 40px;
  background: orange;
  z-index: 111;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(245, 245, 245, 1);
  box-shadow: 0px 8rpx 10rpx 0px rgba(0, 0, 0, 0.1);
  font-size: 24rpx;
  color: white;
}
</style>>
</style>
<style >
page {
  background-color: #ffffff !important;
}
</style>